﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

using agvcontroller.Common.DataBase;
using agvcontroller.Log;

namespace agvcontroller.Common
{
    public class CGuideType
    {
        List<string> _GuideTypeList = new List<string>();

        public List<string>  GuideTypeList
        {
            get { return _GuideTypeList; }
        }

        CAGVCDB AGVCDB;

        Logger Log;

        public CGuideType()
        {
            Log = new Logger("GuideType");

            AGVCDB = CAGVCDB.getInstance();

            GetDataFromDB();
        }

        int GetDataFromDB()
        {
            DataTable table = AGVCDB.AGVCDataSet.Tables["GuideType"];

            try
            {
                _GuideTypeList.Clear();

                foreach (DataRow row in table.Rows)
                {
                    _GuideTypeList.Add(Convert.ToString(row["Type"]));
                }

                if (_GuideTypeList.Count == 0)
                {
                    Log.Info(string.Format("Guide Type List item is empty"));
                }
            }
            catch (Exception ex)
            {
                Log.Exception(string.Format("{0},{1}", ex.Message, ex.StackTrace));
                return CReturnCode.ERR_DATA_ACQUIRING_FAIL;
            }

            return CReturnCode.SUCCESS;
        }
    }
}
